﻿var chart;
function start(){
	var colors = Highcharts.getOptions().colors,name = '综合指标排名';
	var categories = [];
    var data = [];
    colors.push('#FF9933'); //调颜色
    var table = document.getElementById('sjly');
    $('tbody tr', table).each( function(i) {
			var tr = this;
			$('td', tr).each( function(j) {
					if (j == 1) { 
					    categories.push($(this).find('a').html());
					} 
					if (j == 5) { 
						//data.push(parseFloat($(this).find('a').html()));
						data[i] = {
						    y:parseFloat($(this).find('a').html()),
						    color:colors[i]
						};
					}
			});
	});
	function setChart(name, categories, data, color) {
		chart.xAxis[0].setCategories(categories);
		chart.series[0].remove();
		chart.addSeries({
			name: name,
			data: data,
			color: color || '#92A8CD'
		});
	}

	chart = new Highcharts.Chart({
		chart: {
			renderTo: 'container',
			type: 'column'
		},
		title: {
			text: ''
		},
		xAxis: {
			categories: categories
		},
		yAxis: {
			title: {
				text: ''
			}
		},
		plotOptions: {
			column: {
				cursor: 'pointer',
				point: {
					events: {
						click: function() {
							var drilldown = this.drilldown;
							if (drilldown) { // drill down
								setChart(drilldown.name, drilldown.categories, drilldown.data, drilldown.color);
							} else { // restore
								setChart(name, categories, data);
							}
						}
					}
				},
				dataLabels: {
					enabled: true,
					color: colors[0],
					style: {
						fontWeight: 'bold'
					},
					formatter: function() {
						return this.y + '分';
					}
				}
			}
		},
		tooltip: {
			formatter: function() {
				var point = this.point,
					s = this.x +':<b>'+ this.y + '分' ;
				return s;
			}
		},
		series: [{
			name: name,
			data: data,
			color: 'white'
		}],
		exporting: {
			enabled: false
		}
	});
}
$(function(){

$('#tt').tabs({   
     border:false,   
     onSelect:function(title){   
        if(title == "柱形图分析"){
            start();
        } 
    }   

});  
});